package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.CsmDetAddRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.CsmDetRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.LotMtlRequest;
import com.alks.function.service.stockdept.pcfactorystockquery.IPackMtlIOService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-包材出库作业")
@RequiredArgsConstructor
@RoleCheck(prgIds = {"160123"})
public class PackMtlOutController {
    private final IPackMtlIOService service;
    private final String slipType="O";

    @GetMapping("/getPackOutTempQuery")
    @ApiOperation(value = "待出库明细-查询",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo getPackOutTempQuery(){
        return service.getPackTempQuery(slipType);
    }

    @PutMapping("/getPackOutLotMtlQuery")
    @ApiOperation(value = "选择指令材料-分页可条件查询",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo getPackOutLotMtlQuery(@RequestBody LotMtlRequest request) {
        return service.getPackLotMtlQuery(request,slipType);
    }

    @PutMapping("/getPackOutDetQuery")
    @ApiOperation(value = "包材出库明细-可条件查询",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo getPackOutDetQuery(@RequestBody CsmDetRequest request){
        return service.getPackDetQuery(request,slipType);
    }

    @PutMapping("/packOutTempAdd")
    @ApiOperation(value = "待出库批处理-新增",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo packOutTempAdd(@RequestBody@ApiParam("写到这里找我") List<Map<String, String>> request){
        service.packTempAdd(request,slipType);
        return ResponseInfo.ok();
    }

    @PostMapping("/packOutTempUp")
    @ApiOperation(value = "待出库明细修改-更新",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo packOutTempUp(@RequestParam@ApiParam("序号") String item,
                                  @RequestParam(required = false)@ApiParam("数量") Float qty,
                                  @RequestParam(required = false)@ApiParam("备注") String remark){
        return service.packTempUp(item,qty,remark,slipType);
    }

    @PutMapping("/packOutDetAdd")
    @ApiOperation(value = "入库批处理-新增",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo packOutDetAdd(@RequestBody CsmDetAddRequest request){
        return ResponseInfo.ok(service.packDetailAdd(request,slipType));
    }

    @PostMapping("/packOutTempDelete")
    @ApiOperation(value = "待入剩料删除-删除",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo packOutTempDelete(@RequestParam@ApiParam("序号") List<String> item){
        return service.packTempDelete(item,slipType);
    }

    @PostMapping("/packOutDetDelete")
    @ApiOperation(value = "包材出库明细删除-删除",tags = "仓储部-仓储工厂作业-包材出库作业")
    public ResponseInfo packOutDetDelete(@RequestBody List<Integer> idList){
        return service.packDetDelete(idList,slipType);
    }
}
